package Chapter2.Comparing.c9;

public class ThreadTest3 implements Runnable {
    static int x = 1;
    @Override
    public void run() {
        while (true) {
            x++;
            if (x%2 == 0) {
                System.out.print(Thread.currentThread().getName()+":"+ x+".");
            }
            if (x > 100) {
                break;
            }
        }


    }


    public static void main(String[] args) {
        ThreadTest3 threadTest3 = new ThreadTest3();
        /*ThreadTest4 threadTest4 = new ThreadTest4();*/
        Thread thread = new Thread(threadTest3,"偶数");
        /*Thread thread1 = new Thread(threadTest4,"奇数");*/
        Thread thread1 = new Thread(new ThreadTest4(), "奇数");
        thread.start();
        thread1.start();
        /*while (true) {
            y++;
            if (y%2 != 0) {
                System.out.print(" "+y);
            }
            if (y>100){
                break;
            }
        }*/
    }
}

class ThreadTest4 implements Runnable {
    static int y = 1;
    @Override
    public void run() {
        while (true) {
            //y++;
            if (y % 2 != 0) {
                System.out.print(Thread.currentThread().getName()+ ":" + y+".");
            }
            if (y > 99) {
                break;
            }
            y++;
        }
    }
}
